import sys
import MySQL
import Events
import People
        
class PeopleEvents:
    def __init__(self, SQLConn, dBName = "PeopleEvents"):
        self.SQLConn = SQLConn
        
    def AddEntry(self, Person_ID, EventID):
        self.SQLConn.SendCommand("""
         INSERT INTO PeopleEvents (Event_name, Event_Dates)
         VALUES ('%s', '%s')
       """ %(EventName, DateStr))
    
    def RemoveEvent(self, EID):
        self.SQLConn.SendCommand("""    
         DELETE FROM Events where Eve_id=%d
         """ % EID)
        
    def GetAllEvents(self):
        self.SQLConn.SendCommand("SELECT Eve_id, Event_name, Event_Dates FROM Events")
        rows = self.SQLConn.FetchAll ()
        Events = []
        for event in rows:
            Events.append(Event(int(event[0]), event[1], event[2], event[3]))
        return Events
    
    def UpdateEventPeople(self, Peo, Event_name):
       self.SQLConn.SendCommand("""UPDATE Events
                                SET Event_name = '%s'
                                WHERE Peo_id = %d
                                """ % (Event_name, EID))
       
    
if __name__ == '__main__':
    SQL = MySQL.Connection()
    
        
    

    SQL.SendCommand("""CREATE TABLE PEOPLE_EVENTS(
                    Eve_id int,
                    Peo_id int,
                    """)



    #E = Events(SQL)
    #exit = False
    #while not exit:
    #    Input = raw_input("Now What? : ")
    #    if Input == 'exit':
    #        exit = True
    #    if Input == 'new':
    #        Event_Name = raw_input("Event Name : ")
    #        Event_Dates = raw_input("Event Dates : ")
    #        People = raw_input("People : ")
    #        E.AddEvent(Event_Name, Event_Dates, People)
    #        
    #    if Input == 'del':
    #        EID = int(raw_input("Number : "))
    #        E.RemoveEvent(EID)
    #        
    #    if Input == 'print':
    #        Ev =  E.GetAllEvents()
    #        for w in Ev:
    #            print w.EID, w.EventName, w.DateStr
    #            
    #    if Input == 'Update':
    #        ID = int(raw_input("EID : "))
    #        name = raw_input("name : ")
    #        E.UpdateEvent(ID, name)
    #        
    #print "Finished"
    #  
    #SQL.close()  
    #
    
    
  
    
        